home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
bbsutil
/
hsrc_117.zip
/
DISPLAY.C
< prev
next >
Wrap
Text File
|
1990-11-14
|
19KB
|
686 lines
#include "msgg.h"
#include "twindow.h"
#include "keys.h"
#include "headedit.h"
extern word threadstart;
extern WINDOW *ewnd;
extern int wasconfinedx1,wasconfinedy1,wasconfinedx2,wasconfinedy2;
extern void pascal do_recpt(void);
/* This is the main display function for reading messages
(see also read_mess()). This is pretty big and pretty nasty,
but rather efficient, so what the hell... */
int pascal display (word *lastmess,char type) {
register word x;
int x1;
int y1;
word temp;
char *hold;
char *tempo;
char *p;
char caret=0;
char message[133];
char nextkey;
char lines;
char stop;
word numlines;
char findend;
struct nodeidx nid;
int cx,cy;
if (kbhit()) {
nextkey=get_char();
if (nextkey==CTRL_PGUP || nextkey==CTRL_PGDN) return nextkey;
}
Toggler:
highvideo();
current_color=readtextcolor + (readtextback * 16);
clear_message();
dclrwnd(1,6,maxx,maxy-1);
hold=get_text();
if (hold==NULL || *hold==0) return 0;
if(tempo=strstr(hold,"\01URGENT")) {
strncpy(urgent_text,&tempo[8],79);
urgent_text[78]=0;
tempo=strchr(urgent_text,'\r');
if(tempo)*tempo=0;
lstrip(urgent_text);
rstrip(urgent_text);
}
else *lastmsgid=0;
if(!threadstart) {
if(tempo=strstr(hold,"\01MSGID:")) {
strncpy(lastmsgid,&tempo[7],80);
lastmsgid[79]=0;
tempo=strchr(lastmsgid,'\r');
if(tempo)*tempo=0;
lstrip(lastmsgid);
rstrip(lastmsgid);
}
else *lastmsgid=0;
if(tempo=strstr(hold,"\01REPLY:")) {
strncpy(lastreply,&tempo[7],80);
lastreply[79]=0;
tempo=strchr(lastreply,'\r');
if(tempo)*tempo=0;
lstrip(lastreply);
rstrip(lastreply);
}
else *lastreply=0;
}
if(tempo=strstr(hold,"\01ASSOC:")) {
strncpy(assocfile,&tempo[7],80);
assocfile[132]=0;
tempo=strchr(assocfile,'\r');
if(tempo)*tempo=0;
lstrip(assocfile);
rstrip(assocfile);
}
else *assocfile=0;
if (!ctla) strip_seenbys(hold);
strip_blanklines(hold);
if (hold==NULL || &hold==NULL) return 0;
if (kbhit()) {
nextkey=get_char();
if (nextkey==CTRL_PGUP || nextkey==CTRL_PGDN) return nextkey;
}
if (messno>*lastmess) *lastmess=messno;
numlines=0;
line[0]=hold;
lines=findend=stop=0;
cx=1;
cy=6;
p=hold;
while (1) {
Continuing:
if (currarea->attr & ANSI) {
while(*p) {
if(*p=='\01' && !ctla) {
do {
p++;
}while(*p!='\r' && *p);
if(p)p++;
continue;
}
fputc(*p++,stdout);
if(cy>(maxy)) cy=maxy;
if(cy<6) cy=6;
if (kbhit()) {
nextkey=toupper(get_char());
if (nextkey==32) break;
if (nextkey==80) {
while (!kbhit());
get_char();
}
}
}
printf("\r%s",make_ansi(readtextcolor,readtextback));
goto ReLoop;
}
strcpy(message,write_line(&p,maxx,ctla));
tempo=message;
if (currarea->attr & MCI) {
if (strchr(tempo,'^')) {
caret++;
tempo=mci(tempo);
if (strlen(tempo)>maxx) {
if (!findend) lines+=(strlen(tempo)/maxx)+1;
numlines+=(strlen(tempo)/maxx)+1;
}
}
}
if (!findend) {
char altered=0;
if(!hilite) {
if(*tempo=='\01') { /* Highlight kludge lines */
current_color=kludge_fore + (kludge_back * 16);
if(caret) fputs(make_ansi(kludge_fore,kludge_back),stdout);
altered++;
}
else if(isbrktquote(tempo)) { /* Highlight quotes */
current_color=quote_fore+(quote_back * 16);
if(caret)fputs(make_ansi(quote_fore,quote_back),stdout);
altered++;
}
else if(currarea->attr & ECHO) {
if (!strncmp(tempo," * Origin: ",11)) { /* Highlight origins */
current_color=orig_fore+(orig_back * 16);
if(caret)fputs(make_ansi(orig_fore,orig_back),stdout);
altered++;
}
else if (!strncmp(tempo,"--- ",4) || !strcmp(message,"---")) {
lowvideo();
current_color=tear_fore+(tear_back * 16);
if(caret)fputs(make_ansi(tear_fore,tear_back),stdout);
altered++;
}
}
}
if (!caret && !slowprint) {
dputs(cx,cy,tempo);
cy++;
}
else {
gotoxy(cx,cy);
if(slowprint) {
char *p;
unsigned long t1;
p=tempo;
while(*p) {
fputc(*p,stdout);
t1=(unsigned long)biostime(0,0L)+(unsigned long)slowprint;
while((unsigned long)biostime(0,0L)<t1 && t1<(unsigned long)biostime(0,0L)+256L);
p++;
}
slowprint=0;
}
else fputs(tempo,stdout);
cy++;
}
if(altered) {
highvideo();
current_color=readtextcolor + (readtextback * 16);
if(caret)fputs(make_ansi(readtextcolor,readtextback),stdout);
}
caret=0;
lines++;
}
numlines++;
if (numlines>=(maxlines-1)) numlines=0;
line[numlines]=p;
EOFF:
slowprint=0;
if (currarea->attr & ANSI) goto ReLoop;
if ((lines>=(maxy-6)-((currarea->attr & MCI)!=0)) || stop || !*p) {
if (findend) {
clear_message();
findend=0;
numlines-=(maxy-6);
p=(char *)line[numlines];
lines=0;
goto NewPage;
}
stop=0;
if ((numlines>(maxy-6) && lines<(maxy-6)) && !*p) {
numlines-=(maxy-6);
p=(char *)line[numlines];
lines=0;
goto NewPage;
}
while (kbhit()) get_char();
ReLoop:
cursor(cx-1,cy-1);
fputs("\r\x1b[0m",stderr);
RealEnd:
current_color=readheadcolor + (readheadback * 16);
if (!*p) dputs(70,3," END");
else if (numlines<=(maxy-6)) dputs(70,3," TOP");
else dputs(70,3,"MORE");
dprintf(75,3,"%u",numlines);
FreeKey:
if(*urgent_text) {
_anymsg(" URGENT! ",urgent_text);
*urgent_text=0;
}
nextkey=0;
current_color=readtextcolor + (readtextback * 16);
set_help ("readkeys ",0,23);
SHOWMOUSE;
if(usemouse) { /* Allow to roam full screen */
union REGS rg;
rg.x.ax=7;
rg.x.cx=0;
rg.x.dx=((maxx-1)*8);
int86(0x33,&rg,&rg);
rg.x.ax=8;
rg.x.cx=0;
rg.x.dx=((maxy-1)*8);
int86(0x33,&rg,&rg);
wasconfinedx1=0;
wasconfinedy1=0;
wasconfinedx2=((maxx-1)*8);
wasconfinedy2=((maxy-1)*8);
}
while(!kbhit()) {
if(usemouse) {
union REGS rg;
rg.x.ax=3;
int86(0x33,&rg,&rg);
move_mouse(rg.x.cx/8,rg.x.dx/8);
rg.x.ax=5;
rg.x.bx=0; /* Check left button */
int86(0x33,&rg,&rg);
if(rg.x.bx) { /* Button pressed */
rg.x.cx/=8; /* Mouse x */
rg.x.dx/=8; /* Mouse y */
if(rg.x.dx<=1) {
nextkey='/';
break;
}
if(rg.x.cx==0 && rg.x.dx==(maxy-1)) {
nextkey=PGDN;
break;
}
if(rg.x.cx==(maxx-1) && rg.x.dx==(maxy-1)) {
nextkey=PGUP;
break;
}
if(rg.x.dx==3 && rg.x.cx>60) {
nextkey=ALT_A;
break;
}
if(rg.x.dx==2 && rg.x.cx>29 && rg.x.cx<44) {
nextkey=ALT_L;
break;
}
if(rg.x.dx<4) {
nextkey=F7;
break;
}
if(rg.x.dx==4) {
nextkey=CTRL_N;
break;
}
nextkey=toupper(get_screen_char(rg.x.cx,rg.x.dx));
switch((int)nextkey) {
case '': nextkey=CTRL_PGUP;
break;
case 26: nextkey=CTRL_PGDN;
break;
case '': nextkey=DN;
break;
case '': nextkey=UP;
break;
case '≈': nextkey=CTRL_F6;
break;
case 168: set_help ("mousekeys ",0,23);
case '?': HIDEMOUSE;
if (helpfunc) {
if (!helping) {
helping=1;